package com.jifeng.api.crud.controller;

import com.jifeng.api.crud.entity.OrderEntity;
import com.jifeng.api.crud.service.OrderService;
import com.jifeng.api.utils.PageUtils;
import com.jifeng.api.utils.R;
import com.jifeng.api.vo.ReqRentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.Map;


/**
 * 
 *
 * @author jifeng
 * @email 1593140625@qq.com
 * @date 2020-09-17 21:36:32
 */
@RestController
@RequestMapping("crud/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 返回订单状态
     */
    @GetMapping("/get/status")
    public R getOrderStatus(@RequestParam Map<String,Object> params){
        return orderService.getOrderStatus(params);
    }
    /**
     * 手动归还设备
     */
    @PostMapping("/pc/manual/return")
    public R manualReturn(@RequestBody OrderEntity params){
        R rs= orderService.manualReturn(params);
        return rs;
    }

    /**
     * 手动清费
     */
    @PostMapping("/pc/manual/checkout")
    public R manualCheckout(@RequestBody OrderEntity params){
        R rs= orderService.manualCheckout(params);
        return rs;
    }

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 检查费用
     */
    @PostMapping("/checkfee")
    public R checkFee(@RequestBody ReqRentVo params){
        R rs= orderService.checkFee(params);
        return rs;
    }

    /**
     * 设备归还，计算费用
     */
    @PostMapping("/returndevice")
    public R returnDevice(@RequestBody ReqRentVo params){
        R rs= orderService.returnDevice(params);
        return rs;
    }
}
